//
//  MeassageView.m
//  PersonalMessage
//
//  Created by Cakes on 16/4/28.
//  Copyright © 2016年 Cakes. All rights reserved.
//

#import "MeassageView.h"
#define  UIColorRGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]
@interface MeassageView (){
    
    UIButton *button1;
    UIButton *button2;
    UIButton *button3;
    UIButton *button4;
    UIButton *button5;
}


@end

@implementation MeassageView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initUI];
    
    }
    return self;
}

- (void)initUI{
    
    [self setBackgroundColor:UIColorRGBA(237, 237, 237, 1)];
    
    
    UIView *noticeView = [[UIView alloc] initWithFrame:CGRectMake(0, 6.5, [UIScreen mainScreen].bounds.size.width, 49)];
    [noticeView setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:noticeView];
    
    UIImage *image = [UIImage imageNamed:@"beipinglun1"];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, noticeView.bounds.size.height - 20, noticeView.bounds.size.height - 20)];
    [imageView setImage:image];
    [noticeView addSubview:imageView];
    
    UILabel *onelabel = [[UILabel alloc] initWithFrame:CGRectMake(imageView.bounds.size.width - 7.5, - 7.5, 15, 15)];
    [onelabel setText:@"1"];
    [onelabel setTextAlignment:NSTextAlignmentCenter];
    [onelabel setBackgroundColor:[UIColor redColor]];
    onelabel.layer.cornerRadius = 7.5;
    onelabel.font = [UIFont systemFontOfSize:10.0];
    [onelabel setTextColor:[UIColor whiteColor]];
    [onelabel.layer setMasksToBounds:YES];
    [imageView addSubview:onelabel];
    
    UILabel *namelabel = [[UILabel alloc] initWithFrame:CGRectMake(51,18.0, 64.5, 18.0)];
    [namelabel setText:@"系统通知"];
    namelabel.font = [UIFont systemFontOfSize:16.0];
    [namelabel setTextColor:UIColorRGBA(51, 204, 51, 1)];
    [namelabel setBackgroundColor:[UIColor whiteColor]];
    [noticeView addSubview:namelabel];
    
    button1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, noticeView.bounds.size.width, noticeView.bounds.size.height)];
    [button1 addTarget:self action:@selector(MessageEvent:) forControlEvents:UIControlEventTouchUpInside];
    [button1 setTag:100];
    [noticeView addSubview:button1];
    
    UILabel *noticeMessagePrompt = [[UILabel alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 143, 20, 103, noticeView.bounds.size.height - 39)];
//    [noticeMessagePrompt setBackgroundColor:[UIColor blueColor]];
    [noticeView addSubview:noticeMessagePrompt];
    
    UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 22.5, 17.5, 8.5, noticeView.bounds.size.height - 35)];
//    [image1 setBackgroundColor:[UIColor orangeColor]];
    [image1 setImage:[UIImage imageNamed:@"ArrowRight"]];
    [noticeView addSubview:image1];
    
    
    UIView *refactoring = [[UIView alloc] initWithFrame:CGRectMake(0, 62, [UIScreen mainScreen].bounds.size.width, 49)];
    [refactoring setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:refactoring];
    image = [UIImage imageNamed:@"chonggou1"];
    
    UIImageView *refactorImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, noticeView.bounds.size.height - 20, noticeView.bounds.size.height - 20)];
    [refactorImageView setImage:image];
    [refactoring addSubview:refactorImageView];
    
    UILabel *refactorname = [[UILabel alloc] initWithFrame:CGRectMake(51,18.0, 64.5, 18.0)];
    [refactorname setText:@"重构"];
    refactorname.font = [UIFont systemFontOfSize:16.0];
    [refactorname setTextColor:UIColorRGBA(42, 180, 220, 1)];
    [refactorname setBackgroundColor:[UIColor whiteColor]];
    [refactoring addSubview:refactorname];
    
    button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, refactoring.bounds.size.width, refactoring.bounds.size.height)];
    [button2 addTarget:self action:@selector(MessageEvent:) forControlEvents:UIControlEventTouchUpInside];
    [button2 setTag:200];
    [refactoring addSubview:button2];
    
    UILabel *twolabel = [[UILabel alloc] initWithFrame:CGRectMake(imageView.bounds.size.width - 7.5, - 7.5, 15, 15)];
    [twolabel setText:@"12"];
    [twolabel setTextAlignment:NSTextAlignmentCenter];
    [twolabel setBackgroundColor:[UIColor redColor]];
    twolabel.layer.cornerRadius = 7.5;
    [twolabel setTextColor:[UIColor whiteColor]];
    [twolabel.layer setMasksToBounds:YES];
    twolabel.font = [UIFont systemFontOfSize:10.0];
    [refactorImageView addSubview:twolabel];
    UILabel *refactorMessagePrompt = [[UILabel alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 143, 20, 103, noticeView.bounds.size.height - 39)];
//    [refactorMessagePrompt setBackgroundColor:[UIColor blueColor]];
    [refactoring addSubview:refactorMessagePrompt];
    
    UIImageView *image2 = [[UIImageView alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 22.5, 17.5, 8.5,  noticeView.bounds.size.height - 35)];
//    [image2 setBackgroundColor:[UIColor orangeColor]];
    [image2 setImage:[UIImage imageNamed:@"ArrowRigt"]];
    [refactoring addSubview:image2];
    
    UIView *commentsView = [[UIView alloc] initWithFrame:CGRectMake(0, 117.5, [UIScreen mainScreen].bounds.size.width, 49)];
    [commentsView setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:commentsView];
    
    image = [UIImage imageNamed:@"beipinglun1"];
    
    UIImageView *commentsImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, noticeView.bounds.size.height - 20, noticeView.bounds.size.height - 20)];
    [commentsImageView setImage:image];
    [commentsView addSubview:commentsImageView];
    
    UILabel *commentslabel = [[UILabel alloc] initWithFrame:CGRectMake(51,18.0, 64.5, 18.0)];
    [commentslabel setText:@"被评论"];
    commentslabel.font = [UIFont systemFontOfSize:16.0];
    [commentslabel setTextColor:UIColorRGBA(34, 34, 34, 1)];
    [commentslabel setBackgroundColor:[UIColor whiteColor]];
    [commentsView addSubview:commentslabel];
    
    button3 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, commentsView.bounds.size.width, commentsView.bounds.size.height)];
    [button3 setTag:300];
    [button3 addTarget:self action:@selector(MessageEvent:) forControlEvents:UIControlEventTouchUpInside];
//    [button3 setBackgroundColor:[UIColor redColor]];
    [commentsView addSubview:button3];
    
    UILabel *threelabel = [[UILabel alloc] initWithFrame:CGRectMake(imageView.bounds.size.width - 7.5, - 7.5, 15, 15)];
    [threelabel setText:@"9"];
    [threelabel setTextAlignment:NSTextAlignmentCenter];
    [threelabel setBackgroundColor:[UIColor redColor]];
    threelabel.layer.cornerRadius = 7.5;
    [threelabel setTextColor:[UIColor whiteColor]];
    [threelabel.layer setMasksToBounds:YES];
    threelabel.font = [UIFont systemFontOfSize:10.0];
    [commentsImageView addSubview:threelabel];
    
    UILabel *commentsMessagePrompt = [[UILabel alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 143, 20, 103, noticeView.bounds.size.height - 39)];
//    [commentsMessagePrompt setBackgroundColor:[UIColor blueColor]];
    [commentsView addSubview:commentsMessagePrompt];
    
    UIImageView *image3 = [[UIImageView alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 22.5, 17.5, 8.5,  noticeView.bounds.size.height - 35)];
//    [image3 setBackgroundColor:[UIColor orangeColor]];
    [image3 setImage:[UIImage imageNamed:@"ArrowRigt"]];
    [commentsView addSubview:image3];
    
    UIView *focusView = [[UIView alloc] initWithFrame:CGRectMake(0, 167.5,[UIScreen mainScreen].bounds.size.width, 49)];
    [focusView setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:focusView];
    
    image = [UIImage imageNamed:@"guanzhuni1"];
    
    UIImageView *focusImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, noticeView.bounds.size.height - 20, noticeView.bounds.size.height - 20)];
    [focusImageView setImage:image];
    [focusView addSubview:focusImageView];
    
    UILabel *focuslabel = [[UILabel alloc] initWithFrame:CGRectMake(51,18.0, 64.5, 18.0)];
    [focuslabel setText:@"关注你的"];
    focuslabel.font = [UIFont systemFontOfSize:16.0];
    [focuslabel setTextColor:UIColorRGBA(34, 34, 34, 1)];
    [focuslabel setBackgroundColor:[UIColor whiteColor]];
    [focusView addSubview:focuslabel];
    
    button4 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, focusView.bounds.size.width, focusView.bounds.size.height)];
    [button4 setTag:400];
    [button4 addTarget:self action:@selector(MessageEvent:) forControlEvents:UIControlEventTouchUpInside];
    [focusView addSubview:button4];
    
    UILabel *fourlabel = [[UILabel alloc] initWithFrame:CGRectMake(imageView.bounds.size.width - 7.5, - 7.5, 15, 15)];
    [fourlabel setText:@"99"];
    [fourlabel setTextAlignment:NSTextAlignmentCenter];
    [fourlabel setBackgroundColor:[UIColor redColor]];
    fourlabel.layer.cornerRadius = 7.5;
    [fourlabel setTextColor:[UIColor whiteColor]];
    [fourlabel.layer setMasksToBounds:YES];
    fourlabel.font = [UIFont systemFontOfSize:10.0];
    [focusImageView addSubview:fourlabel];
    
    for (int i = 3; i > 0; i--) {
        UIImageView *focusimages = [[UIImageView alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 143 + i * 25, 16.0/2.0, 33, 33)];
        focusimages.layer.cornerRadius = 16.5;
        focusimages.layer.borderWidth = 2;
        focusimages.layer.borderColor = [UIColor whiteColor].CGColor;
//        [focusimages setBackgroundColor:[UIColor blackColor]];
        [focusView addSubview:focusimages];
    }
    
    UIImageView *image4 = [[UIImageView alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 22.5, 17.5, 8.5,  noticeView.bounds.size.height - 35)];
//    [image4 setBackgroundColor:[UIColor orangeColor]];
    [image4 setImage:[UIImage imageNamed:@"ArrowRigt"]];
    [focusView addSubview:image4];
    
    
    UIView *thumbupView = [[UIView alloc] initWithFrame:CGRectMake(0, 217.5, [UIScreen mainScreen].bounds.size.width, 49)];
    [thumbupView setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:thumbupView];
    
    image = [UIImage imageNamed:@"beidianzan1"];
    
    UIImageView *thumbupImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, noticeView.bounds.size.height - 20, noticeView.bounds.size.height - 20)];
    
    [thumbupImageView setImage:image];
    [thumbupView addSubview:thumbupImageView];
    
    UILabel *thumbuplabel = [[UILabel alloc] initWithFrame:CGRectMake(51,18.0, 64.5, 18.0)];
    [thumbuplabel setText:@"被点赞"];
    thumbuplabel.font = [UIFont systemFontOfSize:16.0];
    [thumbuplabel setTextColor:UIColorRGBA(34, 34, 34, 1)];
    [thumbuplabel setBackgroundColor:[UIColor whiteColor]];
    [thumbupView addSubview:thumbuplabel];
    
    button5 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, thumbupView.bounds.size.width, thumbupView.bounds.size.height)];
    [button5 setTag:500];
    [button5 addTarget:self action:@selector(MessageEvent:) forControlEvents:UIControlEventTouchUpInside];
    [thumbupView addSubview:button5];
    
    UILabel *fivelabel = [[UILabel alloc] initWithFrame:CGRectMake(imageView.bounds.size.width - 7.5, - 7.5, 15, 15)];
    [fivelabel setText:@"9"];
    [fivelabel setTextAlignment:NSTextAlignmentCenter];
    [fivelabel setBackgroundColor:[UIColor redColor]];
    fivelabel.layer.cornerRadius = 7.5;
    [fivelabel setTextColor:[UIColor whiteColor]];
    [fivelabel.layer setMasksToBounds:YES];
    fivelabel.font = [UIFont systemFontOfSize:10.0];
    [thumbupImageView addSubview:fivelabel];
    
    UILabel *thumbupMessagePrompt = [[UILabel alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 143, 20, 103, noticeView.bounds.size.height - 39)];
//    [thumbupMessagePrompt setBackgroundColor:[UIColor blueColor]];
    [thumbupView addSubview:thumbupMessagePrompt];
    
    UIImageView *image5 = [[UIImageView alloc] initWithFrame:CGRectMake(noticeView.bounds.size.width - 22.5, 17.5, 8.5,  noticeView.bounds.size.height - 35 )];
//    [image5 setBackgroundColor:[UIColor orangeColor]];
    [image5 setImage:[UIImage imageNamed:@"ArrowRigt"]];
    [thumbupView addSubview:image5];
}



- (void)MessageEvent:(UIButton *)sender
{
    [_delegate MesssageTouch:sender.tag];
}

@end
